# CMake adapter Makefile

SYSTEM := $(shell uname -o)

ifeq ($(SYSTEM), Msys)
CMAKE_GENERATOR = MSYS Makefiles
BUILD_DIR = build-win
endif
ifeq ($(SYSTEM), GNU/Linux)
CMAKE_GENERATOR = Unix Makefiles
BUILD_DIR = build-linux
endif

CMAKE_OPTIONS = -DCMAKE_BUILD_TYPE=$(BUILD_TYPE)

# Special settings for eclipse
ifeq ($(USE_ECLIPSE), yes)
CMAKE_OPTIONS += -DCMAKE_COLOR_MAKEFILE=OFF \
	-DCMAKE_C_FLAGS:STRING="-fmessage-length=0" \
	-DCMAKE_VERBOSE_MAKEFILE=OFF
endif

all: debug

cmake:
	mkdir -p $(BUILD_DIR)
	( cd $(BUILD_DIR); cmake -G"$(CMAKE_GENERATOR)" $(CMAKE_OPTIONS) ../ )

debug: BUILD_TYPE = Debug
debug: cmake
	make -C $(BUILD_DIR)

release: BUILD_TYPE = Release
release: cmake
	make -C $(BUILD_DIR)

clean:
	make -C $(BUILD_DIR) clean

distclean:
	rm -rf $(BUILD_DIR)

.PHONY: all cmake debug release clean distclean